package day2;

public class zy4 {
    public static void main(String[] args) {
            StringBuilder stringBuilder =new StringBuilder();
            StringBuffer stringBuffer =new StringBuffer();
            System.out.println("stringBuilder:");
            long time =System.nanoTime();
            for (int i=0;i<100000;i++){
                stringBuilder.append("i");
            }
            long time1 =System.nanoTime();
            System.out.println("获得"+(time1-time)+"纳秒"+"\n");

            System.out.println("stringBuffer:");
            long time3 =System.nanoTime();
            for (int i=0;i<100000;i++){
                stringBuffer.append("i");
            }
            long time4 =System.nanoTime();
            System.out.println("获得"+(time4-time3)+"纳秒");
    }
}
